package com.tsu.mall.order.Controller;


import com.tsu.mall.common.service.IMemberService;
import com.tsu.mall.common.util.RequestUtil;
import com.tsu.mall.order.entity.MemberAddress;
import com.tsu.mall.order.service.IMemberAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tttttt
 * @since 2023-04-07
 */
@Controller
@RequestMapping("/memberAddress")
public class MemberAddressController {
    @Autowired
    private IMemberAddressService iMemberAddressService;
    @PostMapping("/saveMemberAddress")
    @ResponseBody
    public void saveMemberAddress(MemberAddress memberAddress){
      memberAddress.setMemberId(RequestUtil.getCurrent().getId());
      memberAddress.setDefaultAddress("否");
    iMemberAddressService.save(memberAddress);
    }
    @PostMapping("/selectMemberAddressByAddressId")
    @ResponseBody
    public MemberAddress selectMemberAddressByAddressId(Integer addressId){
       return  iMemberAddressService.selectMemberAddressByAddressId(addressId);
    }
    @PostMapping("/delAddressByAddressId")
    @ResponseBody
    public void delAddressByAddressId(Integer addressId){
        iMemberAddressService.removeById(addressId);
    }
    @PostMapping("/updateMemberAddressByAddressId")
    @ResponseBody
    public void updateMemberAddressByAddressId(Integer addressId){
        iMemberAddressService.updateMemberAddressByAddressId(addressId);
    }
}
